// SelectStudent.java
package Com.StudentControlSystem;

import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class SelectStudent {
    public static void selectStudent() {
        System.out.println("请输入要查询学生信息的学号：");
        Scanner scanner = new Scanner(System.in);
        String inputID = scanner.next();

        if (inputID == null || inputID.trim().isEmpty()) {
            System.out.println("输入的学号不能为空！");
            return;
        }

        Map<String, List<Student>> studentMap = StudentData.getStudentMap();
        if (studentMap.containsKey(inputID)) {
            List<Student> students = studentMap.get(inputID);
            if (students != null && !students.isEmpty()) {
                System.out.println("学号\t姓名\t年龄\t地址");
                for (Student student : students) {
                    System.out.println(student.getID() + "\t" + student.getName() + "\t" + student.getAge() + "岁\t" + student.getAddress());
                }
            }
        } else {
            System.out.println("未找到该学号对应的学生信息！");
        }
    }
}
